package com.lyy.demo.openapi.knife;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

// 自定义swagger3文档信息
@Configuration
@Data
public class Swagger3Config {


    @Value("${lyy.swagger.title:lyy-系统-Swagger3接口文档}")
    private String title;
    @Value("${lyy.swagger.description:-------}")
    private String description;
    @Value("${lyy.swagger.name:lyy-系统}")
    private String name;
    @Value("${lyy.swagger.url:#}")
    private String url;
    @Value("${lyy.swagger.email:#}")
    private String email;
    @Value("${lyy.swagger.version:1.0.0}")
    private String version;


    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .summary(name)
                        .title(title)
                        .version(version)
                        .description(description)
                        .termsOfService(url)
                        .license(new License().name("Apache 2.0")
                                .url(email)));
    }

}

